package com.example.secondhandsysapi.Service;

import com.example.secondhandsysapi.Entity.NoticeInfo;
import com.example.secondhandsysapi.Mapper.NoticeInfoMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@Service
public class NoticeInfoServiceImpl implements NoticeInfoService {

    @Autowired
    private NoticeInfoMapper noticeInfoMapper;

    @Override
    public List<NoticeInfo> getAllNoticeInfo() {
        return noticeInfoMapper.getAllNoticeInfo();
    }

    @Override
    public List<NoticeInfo> getRandomNoticeInfo() {
        return noticeInfoMapper.getRandomNoticeInfo();
    }

    @Override
    public List<NoticeInfo> getInfoByType(String type) {
        return noticeInfoMapper.getInfoByType(type);
    }

    @Override
    public List<NoticeInfo> getInfoByStatus(Integer status) {
        return noticeInfoMapper.getInfoByStatus(status);
    }

    @Override
    public List<NoticeInfo> getInfoByTypeAndStatus(String type, Integer status) {
        return noticeInfoMapper.getInfoByTypeAndStatus(type,status);
    }

    @Override
    public Integer addNoticeInfo(NoticeInfo noticeInfo) {
        return noticeInfoMapper.addNoticeInfo(noticeInfo);
    }

    @Override
    public Integer updateNoticeInfo(NoticeInfo noticeInfo) {
        return noticeInfoMapper.updateNoticeInfo(noticeInfo);
    }

    @Override
    public Integer deleteNoticeInfo(Integer id) {
        return noticeInfoMapper.deleteNoticeInfo(id);
    }


    @Override
    public List<NoticeInfo> getAllNoticeInfo2(String notice_type, String notice_theme) {
        List<NoticeInfo> i=  noticeInfoMapper.getAllNoticeInfo2(notice_type, notice_theme);
        return i;
    }

    @Override
    public List<NoticeInfo> getAllNoticeInfo1() {
        return noticeInfoMapper.getAllNoticeInfo1();
    }

    @Override
    public List<NoticeInfo> getAllNoticeInfoByType(String notice_type) {
        return noticeInfoMapper.getAllNoticeInfoByType(notice_type);
    }

    @Override
    public List<NoticeInfo> getAllNoticeInfoByTheme(String notice_theme) {
        return noticeInfoMapper.getAllNoticeInfoByTheme(notice_theme);
    }

    @Override
    public PageInfo<NoticeInfo> getNoticeInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<NoticeInfo> i= noticeInfoMapper.getAllNoticeInfo1();
        PageInfo<NoticeInfo> pageInfo = new PageInfo<>(i);
        return pageInfo;
    }

    @Override
    public Integer updateStatus(Integer notice_id) {
        Integer i = noticeInfoMapper.updateStatus(notice_id);
        return  1;
    }

    @Override
    public Integer updateCheck_Info(String check_info, Integer notice_id) {
        Integer i=noticeInfoMapper.updateCheck_Info(check_info,notice_id);
        return i;
    }

    @Override
    public NoticeInfo getNoticeDetailsInfoById(Integer notice_id) {
        NoticeInfo result = noticeInfoMapper.getNoticeDetailsInfoById(notice_id);
        return result;
    }

}
